Skip to content

Conversation

@ZERICO2005
Copy link
Contributor

@ZERICO2005 ZERICO2005 commented Sep 1, 2025

Fixed behavior of memrchr when ptr and size are both zero (memrchr(NULL, ch, 0)).

It returns the correct result in all cases except when ptr + (nonzero_size - 1) overflows/wraps-around (such as memrchr(0xFFFFFF, ch, 2)). Since pointer wrap-around is UB (Undefined behavior), I assume this is okay. Fixing the pointer wrap-around case costs 1 byte + 1F.

@ZERICO2005 ZERICO2005 marked this pull request as ready for review September 1, 2025 23:09
@mateoconlechuga mateoconlechuga merged commit e3d53f5 into master Sep 1, 2025
9 checks passed
@mateoconlechuga mateoconlechuga deleted the memrchr_null_zero branch September 1, 2025 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants